import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/page/home/key_think_tank/key_think_tank_rank/key_think_tank_rank_view.dart';

import 'key_think_tank_state.dart';

class KeyThinkTankLogic extends GetxController with GetSingleTickerProviderStateMixin {
  final KeyThinkTankState state = KeyThinkTankState();

  // 如果需要和 TabBarView 联动， TabBar 和 TabBarView 使用同一个 TabController 即可
  late TabController controller;

  @override
  void onInit() {
    super.onInit();
    controller = TabController(vsync: this, length: state.tabs.length);

  }

  @override
  void onReady() {
    super.onReady();
    controller.addListener(() async {
      switch(controller.index) {
        case 3:
          await Get.to(() => const KeyThinkTankRankPage());
          controller.index = 0;
          break;
        default:
          break;
      }
    });
  }

  @override
  void onClose() {
    super.onClose();
    controller.dispose();
  }
}
